package br.ufpe.cin.ip.biblioteca.gui;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JTextField;

public class JNumberField extends JTextField {
	private static final long serialVersionUID = -6743367832206115866L;
	
	public JNumberField() {
		super();
		
		this.addKeyListener(new KeyAdapter() {
			@Override
			public void keyTyped(KeyEvent e) {
				String caracteres = "0123456789";
				
				if( !caracteres.contains(String.valueOf(e.getKeyChar()))) {
					e.consume();
				}
			}
		});
	}
}
